package com.cheng.io.input;

import com.cheng.io.entity.Student;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * transient关键字，序列化时忽略当前属性
 */
public class ObjectInputStreamTest04 {
    public static void main(String[] args) {
        try (
                ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("io/resources/student2"));
        ) {
            Object object = objectInputStream.readObject();
            if (object instanceof Student) System.out.println(object);
        } catch (IOException | ClassNotFoundException e) {
            throw new RuntimeException(e);
        }
    }
}
